package com.neusoft.utils.mybatis;

import java.util.List;

import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.select.Select;
import net.sf.jsqlparser.util.TablesNamesFinder;

public class SQLTest {
	public static void main(String[] args) {
		String sql = "select n.* from webc_list n left join webc_menu m on n.menuId=m.id WHERE n.cmptId = 1477 and n.type = 0 and n.isDelete = 0 order by n.id desc";
		try {
			Statement stmt = CCJSqlParserUtil.parse(sql);
			Select selectStatement = (Select) stmt;
			TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
			List<String> tableList = tablesNamesFinder.getTableList(selectStatement);
			for (String string : tableList) {
				System.out.println(string);
			}
		} catch (JSQLParserException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
